home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / print / hpgl2ps.zip / TICK.C < prev    next >
C/C++ Source or Header  |  1989-08-08  |  1KB  |  56 lines

  1. /* tick.c */
  2. /*
  3.  * tick(type)
  4.  *
  5.  * function for handling the XT,YT commands 
  6.  * in Hewlett-Packard Graphics Language (HP-GL).
  7.  *
  8.  * Written by Gordon Jacobs 
  9.  * University of California, Berkeley , Dept of EECS.
  10.  */
  11.  
  12.  
  13. #include "defn.h"
  14.  
  15. tick(type)
  16. int  type;
  17. {
  18.     float Xtlengthp,Xtlengthn,Ytlengthp,Ytlengthn;
  19.  
  20.     /* Compute tick lengths as a function of viewport dimensions */
  21.     /* Xticks are in Y direction: */
  22.     Xtlengthp = tlp * (ymax - ymin) * XSCALE; 
  23.     Xtlengthn = tln * (ymax - ymin) * XSCALE; 
  24.     /* Yticks are in X direction */
  25.     Ytlengthp = tlp * (xmax - xmin) * YSCALE; 
  26.     Ytlengthn = tln * (xmax - xmin) * YSCALE; 
  27.  
  28.     /* Ticks: Don't mess with position pointers,
  29.      *   just use relative draw and move commands 
  30.      */
  31.     if (type == XTICK) {
  32.     if(tlp != 0.0) {
  33.         lastYmove = absY += Xtlengthp;
  34.         printf("  %g %g %s\n",0.0,Xtlengthp,RMOVE);
  35.         printf("  %g %g %s\n",0.0,-Xtlengthp,RDRAW);
  36.     }
  37.     if(tln != 0.0) {
  38.         lastYmove = absY -= Xtlengthp;
  39.         printf("  %g %g %s\n",0.0,-Xtlengthn,RMOVE);
  40.         printf("  %g %g %s\n",0.0,Xtlengthn,RDRAW);
  41.     }
  42.     }
  43.     else {
  44.     if(tlp != 0.0) {
  45.         lastXmove = absX += Xtlengthp;
  46.         printf("  %g %g %s\n",Ytlengthp,0.0,RMOVE);
  47.         printf("  %g %g %s\n",-Ytlengthp,0.0,RDRAW);
  48.     }
  49.     if(tln != 0.0) {
  50.         lastXmove = absX -= Xtlengthp;
  51.         printf("  %g %g %s\n",-Ytlengthn,0.0,RMOVE);
  52.         printf("  %g %g %s\n",Ytlengthn,0.0,RDRAW);
  53.     }
  54.     }
  55. }
  56.